package com.siecom.nativelibs;

import android.util.Log;

/**
 * Created by zhq on 2016/5/24.
 *
 * 黑科技so文件代理系统by zhq
 */
public class NativeLoad {
    static
    {
        System.loadLibrary("Loadso");
        /**
         * 动态注册jni函数
         * 不需要写对应的c层函数，直接映射对应关系
         * 需要函数的返回类型和入参java层变量签名如(Ljava/lang/String;)I
         *
         */
        int res =  NativeLoad.load_so("libwltdecode.so","Java_com_ivsign_android_IDCReader_IDCReaderSDK_wltInit");
        if(res==0)
            Log.e("loadso", "正确加载so和函数");
        res = NativeLoad.registerJniMapping("init","(Ljava/lang/String;)I");
        if(res==1)
            Log.e("loadso：", "正确重注册jni");

        res =  NativeLoad.load_so("libwltdecode.so","Java_com_ivsign_android_IDCReader_IDCReaderSDK_wltGetBMP");
        if(res==0)
            Log.e("loadso", "正确加载so和函数");
        res = NativeLoad.registerJniMapping("wltGetBMP","([B[B)I");
        if(res==1)
            Log.e("loadso：", "正确重注册jni");

    }
    public static native String test(String str);
    /**
     * 加载so文件和对应的函数名
     * @param soName
     * @param methodName
     * @return
     */
    public static native int load_so(String soName,String methodName);

    /**
     * 映射函数
     * @param javaFunc
     * @param nativeFunc
     * @return
     */
    public static native int registerJniMapping(String javaFunc,String nativeFunc);

    /**
     * 自定义load的函数
     * @param workPath
     * @return
     */
    public  static native int init(String workPath);

    public static  native int wltGetBMP(byte[] wltdata, byte[] licdata);

}
